import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
// 公共路由
export const constantRoutes = [{
    path: '/',
    redirect: "/home"
  },
  {
    path: '/home',
    component: () => import('@/views/home/index'),
    meta: {
      title: '首页'
    }
  },
  {
    path: '/art-gallery',
    component: () => import('@/views/artGallery/index'),
    meta: {
      title: '游林芝'
    },
    redirect:'/art-gallery/intro',
    children: [
        {
            path: 'intro',
            component: () => import('@/views/artGallery/intor'),
            meta: {
                title: '文化馆简介'
            },
        },
        {
            path: 'intro1',
            component: () => import('@/views/artGallery/intor1'),
            meta: {
                title: '关于我们'
            },
        },
        {
            path: 'about1',
            component: () => import('@/views/artGallery/about'),
            meta: {
                title: '联系我们'
            },
        },
        {
            path: 'about',
            component: () => import('@/views/artGallery/about'),
            meta: {
                title: '联系我们'
            },
        },
        {
            path: 'details',
            component: () => import('@/views/artGallery/details'),
            meta: {
              title: '游林芝详情'
            },
          },
    ]
  },
  {
    path: '/consult',
    redirect:'/consult/index',
    component: () => import('@/views/consult/consult'),
    meta: {
      title: '汇资讯'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/consult/index'),
        meta: {
          title: '汇资讯'
        },
      },
      {
        path: 'details',
        component: () => import('@/views/consult/details'),
        meta: {
          title: '汇资讯详情'
        },
      },
    ]
  },
  {
    path: '/activity',
    redirect:'/activity/index',
    component: () => import('@/views/enjoyActivity/activity'),
    meta: {
      title: '享活动'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/enjoyActivity/index'),
        meta: {
          title: '享活动'
        },
      },
      {
        path: 'details',
        component: () => import('@/views/enjoyActivity/details'),
        meta: {
          title: '活动详情'
        },
      },
      {
        path: 'signUp',
        component: () => import('@/views/enjoyActivity/signUp'),
        meta: {
          title: '活动报名'
        },
      },
    ]
  },
  {
    path: '/skill',
    redirect:'/skill/index',
    component: () => import('@/views/studySkill/skill'),
    meta: {
      title: '学才艺'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/studySkill/index'),
        meta: {
          title: '学才艺'
        },
      },
      {
        path: 'details',
        component: () => import('@/views/studySkill/details'),
        meta: {
          title: '学才艺详情'
        },
      },
      {
        path: 'signUp',
        component: () => import('@/views/studySkill/signUp'),
        meta: {
          title: '才艺报名'
        },
      },
    ]
  },
  {
    path: '/reservedSite',
    redirect:'/reservedSite/index',
    component: () => import('@/views/reservedSite/site'),
    meta: {
      title: '订场馆'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/reservedSite/index'),
        meta: {
          title: '订场馆'
        },
      },
      {
        path: 'details',
        component: () => import('@/views/reservedSite/details'),
        meta: {
          title: '订场馆详情'
        },
      },
      {
        path: 'reserved',
        component: () => import('@/views/reservedSite/reserved'),
        meta: {
          title: '订场馆预定'
        },
      },
      {
        path: 'signUp',
        component: () => import('@/views/reservedSite/signUp'),
        meta: {
          title: '订场馆预定详情'
        },
      },
    ]
  },
  {
    path: '/toFair',
    redirect:'/toFair/index',
    component: () => import('@/views/toFair/toFair'),
    meta: {
      title: '赶大集'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/toFair/index'),
        meta: {
          title: '赶大集'
        },
      },
      {
        path: 'details',
        component: () => import('@/views/toFair/details'),
        meta: {
          title: '赶大集详情'
        },
      },
    ]
  },
  {
    path: '/readBook',
    redirect:'/readBook/index',
    component: () => import('@/views/readBook/readBook'),
    meta: {
      title: '读好书'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/readBook/index'),
        meta: {
          title: '读好书'
        },
      },
      {
        path: 'details',
        component: () => import('@/views/readBook/details'),
        meta: {
          title: '读好书详情'
        },
      },
      {
        path: 'article',
        component: () => import('@/views/readBook/article'),
        meta: {
          title: '目录详情'
        },
      },
      {
        path: 'directory',
        component: () => import('@/views/readBook/directory'),
        meta: {
          title: '读好书目录'
        },
      },
    ]
  },
  {
    path: '/wacth',
    redirect:'/wacth/index',
    component: () => import('@/views/wacthLive/wacthLive'),
    meta: {
      title: '赏精品'
    },
    children: [
        {
            path: 'index',
            component: () => import('@/views/wacthLive/index'),
            meta: {
              title: '赏精品'
            },
        },
        {
            path: 'details',
            component: () => import('@/views/wacthLive/details'),
            meta: {
              title: '赏精品详情'
            },
        },
    ]
  },
  {
    path: '/cultural',
    redirect:'/cultural/index',
    component: () => import('@/views/intangibleCultural/cultural'),
    meta: {
      title: '品非遗'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/intangibleCultural/index'),
        meta: {
          title: '品非遗'
        },
      },
      {
        path: 'culturalList',
        component: () => import('@/views/intangibleCultural/culturalList'),
        meta: {
          title: '非遗列表'
        },
      },
      {
        path: 'trendsDetails',
        component: () => import('@/views/intangibleCultural/trendsDetails'),
        meta: {
          title: '非遗动态详情'
        },
      },
      {
        path: 'inheritDetails',
        component: () => import('@/views/intangibleCultural/inheritDetails'),
        meta: {
          title: '非遗传承人详情'
        },
      },
      {
        path: 'projectDetails',
        component: () => import('@/views/intangibleCultural/projectDetails'),
        meta: {
          title: '非遗详情'
        },
      },
      {
        path: 'lawDetails',
        component: () => import('@/views/intangibleCultural/lawDetails'),
        meta: {
          title: '非遗详情'
        },
      },
    ]
  },
  {
    path: '/user',
    redirect:'/user/myActivity',
    component: () => import('@/views/user/index'),
    meta: {
      title: '个人中心'
    },
    children: [
      {
        path: 'myActivity',
        component: () => import('@/views/user/myActivity'),
        meta: {
          title: '我的活动'
        },
      },
      {
        path: 'myCollect',
        component: () => import('@/views/user/myCollect'),
        meta: {
          title: '我的活动'
        },
      },
      {
        path: 'myTrain',
        component: () => import('@/views/user/myTrain'),
        meta: {
          title: '我的培训'
        },
      },
      {
        path: 'myAppointment',
        component: () => import('@/views/user/myAppointment'),
        meta: {
          title: '我的预约'
        },
      },
      {
        path: 'myMessage',
        component: () => import('@/views/user/myMessage'),
        meta: {
          title: '我的消息'
        },
      },
      {
        path: 'myMessageDetails',
        component: () => import('@/views/user/myMessageDetails'),
        meta: {
          title: '消息详情'
        },
      },
      {
        path: 'agreementRe',
        component: () => import('@/views/user/agreementRe'),
        meta: {
          title: '服务协议'
        },
      },
      {
        path: 'agreementCo',
        component: () => import('@/views/user/agreementCo'),
        meta: {
          title: '隐私协议'
        },
      },
      {
        path: 'myAccount',
        component: () => import('@/views/user/myAccount'),
        meta: {
          title: '账户修改'
        },
      },
      {
        path: 'myPassword',
        component: () => import('@/views/user/myPassword'),
        meta: {
          title: '密码修改'
        },
      },
    ]
  },
  // {
  //   path: '/404',
  //   component: () => import('@/views/error/404'),
  // },
  // {
  //   path: '/401',
  //   component: () => import('@/views/error/401'),
  // },
]

// 防止连续点击多次路由报错
let routerPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err)
}

export default new Router({
  mode: 'hash', // 去掉url中的#
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})